import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/LoginPage.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/login',
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/home/layout/LayoutPage.vue'),
    children: [
      {
        path: '/index',
        name: 'Index',
        meta: {
          name: '首页'
        },
        component: () => import('../views/home/index/IndexPage.vue')
      },
      {
        path: '/storeShow',
        name: 'StoreShow',
        meta: {
          name: '用户登录后查看'
        },
        component: () => import('../views/home/eployee/user/StoreList.vue')
      },
      {
        path: '/community',
        name: 'Community',
        meta: {
          name: '社区功能'
        },
        component: () => import('../views/home/eployee/user/CommunityPage.vue')
      },
      {
        path: '/employee',
        name: 'employee',
        meta: {
          title: '员工管理'
        },
        component: () => import('../views/home/eployee/IndexPage.vue'),
        children: [
          // 员工路由
          {
            path: '/staff',
            name: 'staff',
            meta: {
              title: '员工'
            },
            component: () => import('../views/home/eployee/ListPage.vue'),
          },
          // 员工添加路由
          {
            path: '/staff/save',
            name: 'staffSave',
            meta: {
              title: '员工的添加和修改'
            },
            component: () => import('../views/home/eployee/save/staffSave.vue')
          },
          // 员工修改
          {
            path: '/staff/getById/:id',
            name: 'staffSave',
            meta: {
              title: '员工的添加和修改'
            },
            component: () => import('../views/home/eployee/save/staffSave.vue')
          },
          // 住户路由
          {
            path: '/person',
            name: 'person',
            meta: {
              title: '住户'
            },
            component: () => import('../views/home/eployee/personPage.vue'),
          },
          // 住户添加
          {
            path: '/person/save',
            name: 'PersonSave',
            meta: {
              title: '住户添加'
            },
            component: () => import('../views/home/eployee/save/PersonSave.vue')
          },
          // 住户修改
          {
            path: '/person/getById/:id',
            name: 'PersonSave',
            meta: {
              title: '住户修改'
            },
            component: () => import('../views/home/eployee/save/PersonSave.vue')
          },
          // 商铺路由
          {
            path: '/store',
            name: 'store',
            meta: {
              title: '店铺'
            },
            component: () => import('../views/home/eployee/storePage.vue'),
          },
          // 商铺添加
          {
            path: '/store/save',
            name: 'StoreSave',
            component: () => import('../views/home/eployee/save/StoreSave.vue')
          },
          // 商铺修改
          {
            path: '/store/getById/:id',
            name: 'StoreSave',
            component: () => import('../views/home/eployee/save/StoreSave.vue')
          },
        ]
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
